package com.Service;

import com.Dao.MessageDao;
import com.POJO.Message;
import com.Service.Imp.MessageServiceImp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageService extends ServiceImpl<MessageDao, Message> implements MessageServiceImp {
    @Autowired
    MessageDao messageDao;
    public void insert(Message message){
         messageDao.insert(message);
    }


    public List<Message> select(String sendertel,String recipienttel){
        QueryWrapper<Message> queryWrapper = new QueryWrapper<>();
        queryWrapper
                .and(i -> i.eq("sendertel", sendertel).eq("recipienttel", recipienttel))
                .or(i -> i.eq("recipienttel", sendertel).eq("sendertel", recipienttel));

        return messageDao.selectList(queryWrapper);
    }
}
